<%--
  Created by IntelliJ IDEA.
  User: gaosubo
  Date: 2020/9/12
  Time: 18:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>结题等级调整</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .btn {
        text-align: right;
    }
    .item img {
        height: 40px;
    }

    .item{
        line-height: 40px;
        margin-top: 8px;
        margin: 8px;
        margin-left: 20px;
    }
    .layui-icon-ok{
        margin-top: 6px;
    }
    .operationDiv{
        position: absolute;
        width: auto;
        border: #ccc 1px solid;
        border-radius: 4px;
        background-color: #ffffff;
        z-index: 99;
    }
    .operationDiv span{
        cursor: pointer;
        display: block;
        /*width: auto;*/
        height: 20px;
        padding: 5px 0;
        line-height: 20px;
        font-size: 16px;
        text-align: center;
    }
    .operationDiv span:hover{
        background-color: green;
        color: #fff;
    }
</style>
<body>
<div>
    <div class="item">
        <div class="item">
            <img src="../img/yeji.png" alt="" style="margin: 0 5px 0 20px;">
            <span style="font-size: 22px;display: inline-block;vertical-align: middle;">结题等级调整</span>
        </div>
    </div>
    <hr class="layui-bg-blue">
    <div>
        <div class="btn">
            <div style="margin-left: 10px;float: left" class="layui-form">
                <input type="radio" checked name="status"  lay-filter="status" value="1" title="结题">
                <input type="radio" name="status" value="2"  lay-filter="status" title="未结题">
            </div>
            <div>
                <button type="button" class="layui-btn immp layui-btn-sm "  style="margin-right: 15px; display: none" >
                    总分百分百筛选
                </button>
                <button type="button" class="layui-btn immp layui-btn-sm " id="del" style="margin-right: 15px" >
                    <i class="layui-icon">&#xe601;</i>
                    导出
                </button>
            </div>
        </div>
    </div>
    <div>
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
</div>


</body>
</html>
<script type="text/html" id="barDemo">
    <div class="layui-btn-container">
        <a class="layui-btn layui-btn-xs" lay-event="look">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="addCheckData">修改学段学分</a>
        <a class="layui-btn layui-btn-xs" lay-event="editCheckData">修改等级</a>
    </div>
</script>
<script>
    var tableInt2;

    layui.use(['table', 'layer', 'form','laydate'], function () {
        var table = layui.table
            , layer = layui.layer
            , form = layui.form
            , laydate = layui.laydate

        $(document).ready(function(){
            form.render();
        });

        var tableInt = table.render({
            elem: '#test'
            , url: '/cnclusion/getAllData'
            , where: {
                type: "1"
            }
            , defaultToolbar: ['']
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'topicName', title: '项目名称'}
                , {field: 'planName', title: '申报计划名称'}
                , {field: 'trOther2', title: '学段评分'}
                , {field: 'reviewFraction', title: '专家平均分'}
                , {field: 'zongfen', title: '总分', align: 'center'}
                , {field: 'dengji', title: '等级'}
                , {field: 'trOther6', title: '课题组意见'}
                , {field: 'trOther9', title: '科研管理部门意见'}
                , {field: 'names', title: '项目成员'}
                , {field: 'headUserName', title: '负责人'}
                , {field: 'type',width:250, title: '操作', toolbar: '#barDemo'}
            ]],
            page:true,
        });

        function noToolTbale(type) {
             tableInt2 = table.render({
                elem: '#test'
                , url: '/cnclusion/getAllData'
                , where: {
                    type: type
                }
                , defaultToolbar: ['']
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'topicName', title: '项目名称'}
                    , {field: 'planName', title: '申报计划名称'}
                     , {field: 'trOther2', title: '学段评分'}
                     , {field: 'reviewFraction', title: '专家平均分'}
                     , {field: 'zongfen', title: '总分', align: 'center'}
                     , {field: 'dengji', title: '等级'}
                     , {field: 'trOther6', title: '课题组意见'}
                     , {field: 'trOther9', title: '科研管理部门意见'}
                    , {field: 'names', title: '项目成员'}
                    , {field: 'headUserName', title: '负责人'}
                ]],
                page:true,
            });
        }

        //监听顶部单选按钮
        form.on('radio(status)', function(data){
            switch (data.value) {
                case "1":
                    tableInt.reload({
                        where: {
                            type: "1"
                        }
                    });
                    break;
                case "2":
                    noToolTbale(2)
                    break;
            }
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            var fil = empty(data.trOther6);
            if(fil == "" || fil == undefined || fil == "undefind"){
                var aName = "";
                var aId = "";
            }else{
                var aName = fil.split(",")[1];
                var aId = fil.split(",")[0];
            }
            if(obj.event === 'addCheckData') {
                layer.open({
                    type: 1,
                    title: '修改学段学分',
                    btn: ['确定', '取消'],
                    shade: 0.5,
                    area: ['20%', '21%'],
                    content:' <div class="layui-form-item" style="margin-top: 10px">\n' +
                        '    <div class="layui-inline">\n' +
                        '      <label class="layui-form-label">学段评分</label>\n' +
                        '      <div class="layui-input-inline">\n' +
                        '        <input id="trOther2" type="tel" name="trOther2" lay-verify="required" autocomplete="off" class="layui-input">\n' +
                        '      </div>\n' +
                        '    </div>\n' +
                        '  </div>',
                    success: function () {
                        var num = data.trOther6;
                        $("#trOther2").val(data.trOther2);
                        form.render();
                    },
                    yes:function (index) {
                        $.ajax({
                            url: '/conclusion_review_result/uploadScore',
                            dataType: 'json',
                            type: 'get',
                            data: {
                                trOther2: $('input[name="trOther2"]').val()
                                , trId: data.trId
                            },
                            success: function (res) {
                                if (res.code == 0) {
                                    // 获取当前页签的值
                                    var pageType = $('input[name="status"]:checked').val()
                                    switch (pageType) {
                                        case "1":
                                            tableInt.reload({
                                                where: {
                                                    type: "1"
                                                }
                                            });
                                            break;
                                        case "2":
                                            noToolTbale(2)
                                            break;
                                    }
                                    layer.msg("修改成功", {time: 1500, icon: 1});

                                } else {
                                    layer.msg("修改失败", {time: 1500, icon: 2});
                                }
                                layer.close(index);
                            }
                        });
                    }
                });
            }
            if(obj.event === 'editCheckData'){
                layer.open({
                    type: 1,
                    title: '修改等级',
                    btn: ['确定', '取消'],
                    shade: 0.5,
                    area: ['32%', '40%'],
                    content:'<div id="radioBox" style="margin-left: 30px;margin-top:20px;float: left;" class="layui-form">'+
                    '<input type="radio"  name="status"  lay-filter="editstatus" value="1" title="优秀">'+
                    '<input type="radio" name="status" value="2"  lay-filter="editstatus" title="良好"><input type="radio" name="status" value="3"  lay-filter="editstatus" title="合格">'+
                    '</div>',
                    success: function () {
                        var dengji = data.dengji;
                        if(dengji == "优秀"){
                            $("#radioBox").find('input[title="优秀"]').attr("checked",true);
                        }else  if(dengji == "合格"){
                            $("#radioBox").find('input[title="合格"]').attr("checked",true);
                        }else if(dengji == "良好"){
                            $("#radioBox").find('input[title="良好"]').attr("checked",true);
                        }
                        form.render();
                    },
                    yes:function (index) {
                        layer.close(index);
                        var len = $("#radioBox").find(".layui-form-radioed").length;
                        if(len>0){
                            var trIds =  data.trId + ",";
                            var status = $("#radioBox").find(".layui-form-radioed").prev("input").attr("title");
                            $.ajax({
                                url: '/cnclusion/updateGrade',
                                dataType: 'json',
                                type: 'post',
                                data:{
                                    trIds:trIds,
                                    status:status
                                },
                                success: function (res) {
                                    if(res.code == 0){
                                        layer.msg(res.msg);
                                        tableInt.reload();
                                    }else{
                                        layer.msg(res.msg);
                                    }
                                }
                            });
                        }else{
                            layer.msg('请选择定级进行修改');
                            return false;
                        }
                    }
                });
            }
            if(obj.event === 'look'){
                layer.open({
                    type: 1,
                    title: '查看',
                    btn: ['确定', '取消'],
                    shade: 0.5,
                    area: ['600px', '70%'],
                    content: '<div id="cont" style="margin: 10px">\n' +
                    '            <div class="layui-form-item" style="margin-top: 15px">\n' +
                    '                <div class="layui-inline">\n' +
                    '                   <span style="color:red">*</span><label class="layui-form-label">项目名称:</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <input type="text" name="planName" disabled lay-verify="required|phone" value="'+empty(data.topicName)+'" autocomplete="off"\n' +
                    '                               class="layui-input required">\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="layui-form-item" style="margin-top: 15px">\n' +
                    '                <div class="layui-inline">\n' +
                    '                   <span style="color:red">*</span><label class="layui-form-label">申报计划:</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <input type="text" name="planName" disabled lay-verify="required|phone" autocomplete="off"\n' +
                    '                               class="layui-input required" value="'+empty(data.planName)+'">\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    ' <div class="layui-inline share">\n' +
                    '                    <label class="layui-form-label">负责人:</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <input type="text" id="rescueUser" user_id="" value="'+empty(data.headUserName)+'" lay-verify="url" autocomplete="off" class="layui-input" disabled style="width: 192px">\n' +
                    '                    </div>\n' +
                    '                </div>'+
                    ' <div class="layui-form-item"  style="margin-top:15px">\n' +
                    '    <label class="layui-form-label" style="width: 100px;">学段意见:</label>\n' +
                    '    <div class="layui-input-inline" id="yj" style="width: 300px;padding: 9px 0;">' +
                    '        <div onmouseenter="shover($(this))" onmouseleave="sover($(this))"><span  style="color:green;cursor: pointer;width: 100%;display: inline-block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" attachName="' + aName + '" attachId="' + aId + '"  class="layui-table-link aUploadFile giv">' + "【" + aName + "】" + '</span><div class="operationDiv" style="display: none;"><span href="javascript:;" class="spanNa" style="cursor: pointer;"></span><span class="" attachName="' + aName + '" attachId="' + aId + '" onclick="down($(this))" >下载</span></div></div><br style="line-height: 1px;">'+
                    '</div>' +
                    '</div>' +
                    '            <div class="layui-form-item" style="margin-top: 15px">\n' +
                    '                <div class="layui-inline">\n' +
                    '                   <span style="color:red">*</span><label class="layui-form-label">学段评分:</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <input type="text" name="trOther2" disabled lay-verify="required|phone" autocomplete="off"\n' +
                    '                               class="layui-input required"  value="'+empty(data.trOther2)+'">\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="layui-form-item" style="margin-top: 15px">\n' +
                    '                <div class="layui-inline">\n' +
                    '                   <span style="color:red">*</span><label class="layui-form-label">专家平均分:</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <input type="text" name="planName" disabled lay-verify="required|phone" autocomplete="off"\n' +
                    '                               class="layui-input required" value="'+empty(data.reviewFraction)+'">\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n'+
                    '        </form>\n' +
                    '    </div>',
                    success: function () {
                        if(fil == "" || fil == undefined || fil == "undefind"){
                            $("#yj").html("");
                        }
                        //附件上传
                        form.render();
                    },
                    yes:function (index) {
                        layer.close(index);
                    }
                });
            }
        });
    });
    //判断空的方法
    function empty(name){
        if(name==undefined||name==''){
            return ''
        }else{
            return name
        }
    }
    // 鼠标移入
    function shover(e) {
        e.find(".operationDiv").css("display","block");
        e.find("span.spanNa").html(e.find(".giv").html());
    }
    // 鼠标移出
    function sover(e) {
        e.find(".operationDiv").css("display","none");
    }
    // 下载
    function down(e) {
        var attachid = e.parents(".operationDiv").prev("span.giv").attr("attachid");
        if(attachid == undefined || attachid=='' || attachid == "undefined"){
            layer.msg("文件损坏或未上传附件")
        }else{
            window.location.href = "/equipment/limsDownload?model=conclusion&attachId=" +attachid
        }
    }
</script>
